home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Carousel
/
CAROUSEL.cdr
/
mactosh
/
utilprn
/
hpdeskje.sit
/
HPDJet ƒ
/
dialog_item_handling.c
< prev
next >
Wrap
Text File
|
1989-04-02
|
5KB
|
227 lines
/* 02.04.1989 amn (latest edit) */
/* dialog_item_handling.c - printer driver for Macintosh and HP DeskJet, dialog subroutines. */
/* Authors: Ari Mujunen (amn@hutcs.hut.fi) and Olli Arnberg (oar@hutcs.hut.fi). */
/* Copyright Ari Mujunen, Olli Arnberg 1989. */
/* You may redistribute the driver (=printer resource file, source files, */
/* documentation file(s), and the file 'Copyright and Source Offer') */
/* only _non-commercially_ and _in its entirety_. */
/* See the file 'Copyright and Source Offer' and/or documentation for details. */
/* Acknowledgements: Special thanks to Mr. Earle R. Horton for his 'Daisy' */
/* daisywheel printer driver and its source code published in 'MacTutor', Nov-Dec 1987. */
/* This driver served as a basis and inspiration for our work. It also */
/* proofed that a Macintosh printer driver can be done despite the lack of */
/* documentation from Apple. */
/* Change history: */
/* Version When Who Why */
/* 2.1 02.04.1989 amn,oar Released version. */
void
pushRadioButton(theDialog, itemHit, first, last)
DIALOG_PTR_TYPE_TODAY theDialog;
int itemHit;
int first;
int last;
{
int itemtype, i;
Handle itemhandle;
Rect itemrect;
if (first <= 0)
return;
for (i=first-1; last-i++;) {
GetDItem(theDialog, i, &itemtype, &itemhandle, &itemrect);
if (itemtype == (ctrlItem + radCtrl))
if (i==itemHit)
SetCtlValue(itemhandle, 1);
else
SetCtlValue(itemhandle, 0);
}
} /* pushRadioButton */
int
whichRadioButton(theDialog, first, last)
DIALOG_PTR_TYPE_TODAY theDialog;
int first;
int last;
{
int itemtype, i;
Handle itemhandle;
Rect itemrect;
if (first <= 0)
return(-1);
for (i=first-1; last-i++;) {
GetDItem(theDialog, i, &itemtype, &itemhandle, &itemrect);
if (itemtype == (ctrlItem + radCtrl))
if (GetCtlValue(itemhandle) == 1)
return(i-first);
}
return(-1);
} /* whichRadioButton */
Boolean
pushCheckBox(theDialog, itemHit)
DIALOG_PTR_TYPE_TODAY theDialog;
int itemHit;
{
int itemtype, i;
Handle itemhandle;
Rect itemrect;
if (itemHit <= 0)
return(FALSE);
GetDItem(theDialog, itemHit, &itemtype, &itemhandle, &itemrect);
if (itemtype == (ctrlItem + chkCtrl)) {
i = GetCtlValue(itemhandle);
SetCtlValue(itemhandle, (i = ((i!=0)?0:1)) );
return(i);
}
return(FALSE);
} /* pushCheckBox */
void
deActivateControls(theDialog, first, last)
DIALOG_PTR_TYPE_TODAY theDialog;
int first;
int last;
{
int itemtype, i;
Handle itemhandle;
Rect itemrect;
if (first <= 0)
return;
for (i=first-1; last-i++;) {
GetDItem(theDialog, i, &itemtype, &itemhandle, &itemrect);
if ((itemtype >= ctrlItem) && (itemtype <= (ctrlItem + resCtrl)))
HiliteControl(itemhandle, 255);
}
} /* deActivateControls */
void
activateControls(theDialog, first, last)
DIALOG_PTR_TYPE_TODAY theDialog;
int first;
int last;
{
int itemtype, i;
Handle itemhandle;
Rect itemrect;
if (first <= 0)
return;
for (i=first-1; last-i++;) {
GetDItem(theDialog, i, &itemtype, &itemhandle, &itemrect);
if ((itemtype >= ctrlItem) && (itemtype <= (ctrlItem + resCtrl)))
HiliteControl(itemhandle, 0);
}
} /* activateControls */
void
forceValueToControls(theDialog, theValue, first, last)
DIALOG_PTR_TYPE_TODAY theDialog;
int theValue;
int first;
int last;
{
int itemtype, i;
Handle itemhandle;
Rect itemrect;
if (first <= 0)
return;
for (i=first-1; last-i++;) {
GetDItem(theDialog, i, &itemtype, &itemhandle, &itemrect);
if ((itemtype >= ctrlItem) && (itemtype <= (ctrlItem + resCtrl)))
SetCtlValue(itemhandle, theValue);
}
} /* forceValueToControls */
Boolean
controlIsOn(theDialog, itemHit)
DIALOG_PTR_TYPE_TODAY theDialog;
int itemHit;
{
int itemtype, i;
Handle itemhandle;
Rect itemrect;
if (itemHit <= 0)
return(FALSE);
GetDItem(theDialog, itemHit, &itemtype, &itemhandle, &itemrect);
if ((itemtype >= ctrlItem) && (itemtype <= (ctrlItem + resCtrl)))
return(GetCtlValue(itemhandle) != 0);
return(FALSE);
} /* controlIsOn */
void
frameButton(theDialog, theButton)
DIALOG_PTR_TYPE_TODAY theDialog;
int theButton;
{
int itemtype;
Handle itemhandle;
Rect itemrect;
GetDItem(theDialog, theButton, &itemtype, &itemhandle, &itemrect);
PenSize(3, 3);
InsetRect(&itemrect, -4, -4);
FrameRoundRect(&itemrect, 16, 16);
}
void
setStringItemToInt(theDialog, theItem, theInt)
DIALOG_PTR_TYPE_TODAY theDialog;
int theItem;
int theInt;
{
int itemtype;
Handle itemhandle;
Rect itemrect;
Str255 numAsString;
if (theItem <= 0)
return;
NumToString((long)theInt, numAsString);
GetDItem(theDialog, theItem, &itemtype, &itemhandle, &itemrect);
itemtype &= ~itemDisable; /* regardless of whether item is disabled or not */
if ((itemtype == statText) || (itemtype == editText))
SetIText(itemhandle, numAsString);
} /* setStringItemToInt */
int
getStringItemAsInt(theDialog, theItem)
DIALOG_PTR_TYPE_TODAY theDialog;
int theItem;
{
int itemtype;
Handle itemhandle;
Rect itemrect;
Str255 numAsString;
long theLong;
if (theItem <= 0)
return(0);
GetDItem(theDialog, theItem, &itemtype, &itemhandle, &itemrect);
itemtype &= ~itemDisable; /* regardless of whether item is disabled or not */
if ((itemtype == statText) || (itemtype == editText)) {
GetIText(itemhandle, &numAsString);
StringToNum(numAsString, &theLong);
return((int)theLong);
}
return(0);
} /* getStringItemAsInt */